package com.eleclab.modele;

import com.eleclab.traitement.Complexe;

import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;

/* TODO
 * - Ajouter les attributs
 * - Ajouter constructeur, setters, getters
 */

public class Generateur extends Composant{
    
    
    protected static  float frequence=0;

    
    public Generateur(String aNom, int ax,int ay, float aAmplitude, float aFrequence) {
        super(aNom,"gene",ax,ay, 'h', "generateur");
        this.amplitude=aAmplitude;
        this.impedance=new Complexe();
        this.frequence=aFrequence;
    }
    
    public void setValeur(float newValeur){
        if(newValeur>0){
            amplitude=newValeur;
        } else {
            System.out.println("inductance non positive!");
            
        }
    }
    public void calculImpedance(){
        this.impedance=new Complexe();
    }
    
    public float getValeur(){
        return amplitude;
    }
    
    public float getFrequence(){
        return this.frequence;
    }
    
    public int getXS(){
        return this.x + this.symbole.getWidth(null)/2-1;
    }
    
    public int getY(){
        return this.y+this.h;
    }
    
    public int getYS(){
        return this.y+10;
    }
    
    public void draw(Graphics g){
        g.drawImage(this.symbole, this.x, this.y, null);        
        if(this.selected){  
            Graphics2D g2d = (Graphics2D) g;
            g2d.setStroke(new BasicStroke(1));
            g.setColor(Color.GRAY);
            g.drawRect((int)dimensions.getX()-5, (int)dimensions.getY()-5,(int) dimensions.getWidth()+10, (int)dimensions.getHeight()+10);
            g.setColor(Color.BLACK);
            g2d.setStroke(new BasicStroke(3));
        }
    }
    
}
